home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # connect-ether-fddi.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: connect-ether-fddi.cgi,v 1.43 1997/04/17 23:43:37 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); }
-
- $myname = "connect-ether-fddi.cgi";
- $temp = "task.tmp";
- $action= "connect-ether-fddi.cgi?loop";
-
- $it = "<td align=right><font size=4>";
- $ni = "</font></td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('interface','address','netmask');
-
- &get_fields;
-
- &getList;
-
- if ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- $go = "/tasks/connect-end.cgi?e";
- #printf("Location: %s%c%c",$go,10,10);
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
-
- &generic;
-
- sub get_iflabel {
- $_ = $_[0];
- if( (/^et/) || (/^ec/) || (/^ee/) || (/^enp/) ) {
- $lb = "Ethernet $_";
- }
- elsif (/^egl/) {
- $lb = "EFast Eagle $_";
- }
- elsif (/^fxp/) {
- $lb = "EFast FXP $_";
- }
- elsif (/^ep/) {
- $lb = "EPlex Ether $_";
- }
- elsif (/^ipg/) {
- $lb = "FDDIXPress $_";
- }
- elsif (/^xpi/) {
- $lb = "FDDI $_";
- }
- elsif ( (/^fv/) || (/^mtr/) || (/^gtr/) ) {
- $lb = "TokenRing $_";
- }
- elsif (/^ef/) {
- $lb = "100BaseTx Ether $_";
- }
- elsif (/^atm/) {
- $lb = "ATM $_";
- }
- elsif (/^hippi/) {
- $lb = "HIPPI $_";
- }
- else {
- $lb = $_;
- }
- $lb;
- }
-
- sub readValues {
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- foreach $arg (@find_vals) {
- if ($arg eq $items[0]) {
- if ($items[1] ne "\n") {
- $vals{$arg} = $items[1];
- chop $vals{$arg};
- }
- }
- }
- }
- close(IN);
- }
-
- sub errorCheck {
- &error("Network interface IP address required.") if !$fld{'address'};
- &error("Invalid IP address.") if &check_ipaddr($fld{'address'});
- &error("Netmask required.") if !$fld{'netmask'};
- &error("Invalid netmask.") if &check_netmask($fld{'netmask'});
- }
-
- sub error {
- $error = $_[0];
- %vals = %fld;
- @items = split(/\s+/,$vals{'interface'});
- $vals{'interface'} = $items[1];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- undef %terms;
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- chop $items[1];
- $terms{$items[0]} = $items[1];
- }
- close(IN);
- foreach $arg (@find_vals) {
- $terms{$arg} = $fld{$arg};
- }
- open(OUT,"> $temp");
- foreach $arg (keys(%terms)) {
- print OUT "$arg=$terms{$arg}\n";
- }
- close(OUT);
- }
-
- sub getList {
- undef @IFlist;
- undef @IPlist;
- open(IN,"/usr/OnRamp/bin/htnetwork | ");
- $needMask = 1;
- while(<IN>) {
- @items = split(/:/);
- if ($items[0] ne '0') {
- if ($needMask) {
- $vals{'netmask'} = $items[4];
- $vals{'address'} = $items[3];
- $needMask = 0;
- }
- push(@IFlist,$items[1]);
- push(@IPlist,$items[2]);
- }
- }
- close(IN);
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>Ethernet-FDDI Configuration</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- # JavaScript
- print "
- $js_error_box
- $js_ip
- function Next() {
- form = document.ether;
- if (form.address.value == \"\") {
- errorBox (form.address, \"The network interface IP address is required.\");
- return;
- }
- if (!testIPaddress(form.address.value, 0)) {
- errorBox (form.address, \"The network interface address is invalid.\");
- return;
- }
- if (form.netmask.value == \"\") {
- errorBox (form.netmask, \"The netmask is required.\");
- return;
- }
- if (!testIPaddress(form.netmask.value, 1)) {
- errorBox (form.netmask, \"The netmask is invalid.\");
- return;
- }
- setTimeout('form.submit()',0);
- return;
- }\n";
-
- print "//-->\n";
- print "</script></head>\n\n";
-
- print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
-
- if ($error) {
- print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
- }
- print "<i>$message</i>";
-
- print "<table width=100%>",
- "<tr><th align=left><h1>Ethernet-FDDI Configuration</h1></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
- " <a href=\"/tasks/Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n\n";
-
- printf("<form name=\"ether\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>";
-
- undef @locList;
- for($i=0;$i<=$#IFlist;$i++) {
- $label = &get_iflabel($IFlist[$i]);
- push(@locList,"$label");
- }
-
- print "<tr>$bo Device name for the network interface: $nb \n$it",
- &select_list("interface",$vals{'interface'},*locList),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The IRIX operating system assigns a device name to each network
- interface that it detects on the Internet Gateway when the system
- is powered on. Select the device name of the interface that you plan
- to use for the connection to your Internet service provider.
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo IP address of the network interface: $nb \n$it",
- &text("address",$vals{'address'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- Each network interface must be assigned an IP address that identifies
- it to the network. An Internet address has four parts: each part,
- or octet, is separated by a dot and contains a decimal value in the
- range of 0 to 255. A portion of the address (usually the first two or
- three octets) designates a network, and the remaining octet designates
- a host on the network. Your ISP should have assigned you an address
- to use for this interface, or a range of addresses from which you must
- assign one.
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo Netmask for your network: $nb \n$it",
- &text("netmask",$vals{'netmask'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- A network mask is applied to an Internet address to designate the
- portion of the address that identifies the host. Enter your network
- mask in dot notation (four dot-separated numbers) or as a hexadecimal
- number. Your ISP should have specified the network mask for this
- network.
- </td></tr>\n";
- print "</table></center>\n";
-
- print '<MAP NAME="js_map1">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<MAP NAME="js_map2">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map2" align="right">';
- print "\n";
- print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
-
- print "\n</form></body></html>";
- }
-